/*
 * relay.cpp
 *
 *  Created on: 2010-2-7
 *      Author: gavinweng
 */

#include "simulator.h"
#include "relay.h"

extern MapBlock *mapblock[SIZE][SIZE];

Relay::Relay()
{
}

Relay::Relay( const RFProperty& relayproperty, int num )
:RFUnit(relayproperty.x, relayproperty.y, relayproperty.height), num(num)
{
	state = OFF;
	userlist.clear();
	capacity = .0;
	for (int i = 0; i < CHANNEL; i++)
	{
		power[i] = relayproperty.power[i];
		bandwidth[i] = relayproperty.bandwidth[i];
		band[i] = 0.0;
		chanOrder[i] = i;
	}
	ChanOrder();
	// Calculate Path Loss Matrix. Shall not be changed during simulation.
	for(int i = 0; i < SIZE; i++)
	{
		for(int j = 0; j < SIZE; j++ )
		{
			pathloss[i][j] = CalculatePathLoss(i, j, x, y);
		}
	}
	Reset();
}
